module D{
    export class RoomData{
        /** 游戏类型ID */
        public kindID:number;
        /** 房间ID */
        public serverID:number;
        /** 游戏客户端类名 */
        public kindClass:string;
        /** 房间类型2游戏币 8练习房 32房卡房 */
        public roomType:number;
        /** 房间名字 */
        public name:string;
        /** 进入限制 */
        public baseScore:number;
        /** 房间最大限制 */
        public limitScore:number;
        /** 房间单元积分 */
        public cellScore:number;

        /** 房间消息处理 */
        public static onMessage(msg:any):void{
            switch(msg[1]){
                case 99:{ //收到房间列表
                    App.roomList = [];
                    for(let i=0;i<msg[2].wKindID.length;i++){
                        let rm = new RoomData();
                        rm.kindID = msg[2].wKindID[i];
                        rm.serverID = msg[2].wServerID[i];
                        rm.name = msg[2].szServerName[i];
                        rm.baseScore = msg[2].lBaseScore[i];
                        rm.limitScore = msg[2].lLimitScore[i];
                        rm.roomType = msg[2].T[i];
                        rm.cellScore = msg[2].lCellScore[i];
                        App.roomList.push(rm);
                    }
                    break;
                }case 100:{ //切房间成功
                    if(App.roomData.serverID == msg[2].port){ //进入跟请求的是相同的房间
                        App.net.send([8,9]); //游戏房间登陆
                    }else{

                    }
                    break;
                }case 101:{ //切房间失败
                    break;
                }
            }
        }

        /** 进入房间 */
        public static enter(rm:RoomData):void{
            App.roomData = rm;
            App.net.send('[2,1,{"port":' + rm.serverID + '}]');
        }
    }
}